{extend name="base/index"/}
{block name="page_location"}
<div class="row">
	<div class="col-12">
		<div class="page-title-box">
			<div class="page-title-right">
				<ol class="breadcrumb m-0">
					<li class="breadcrumb-item"><a href="{:url('index/index')}">管理中心</a></li>
					<li class="breadcrumb-item active"><i class="iconfont icon-angle-right"></i>主栏目管理</li>
				</ol>
			</div>
			<h4 class="page-title">
				所有栏目
				<a href="javascript:;" class="btn btn-success btn-sm ml-3" data-toggle="modal" data-target="#edit_box" id="add_cats_btn">创建新的栏目</a>
			</h4>
		</div>
	</div>
</div>
{/block}
{block name="body"}
<div class="row" id="cats_page">
	<div class="col-12">
		<div class="card">
			<div class="card-body">
				<form class="form-inline" style="margin-bottom:10px;">
					<div class="input-group">
						<div class="input-group-prepend">
							<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
							 aria-expanded="false">选择</button>
							<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 37px, 0px);">
								<a href="javascript:;" class="dropdown-item check_select_btn" attr-type="all" attr-bind="check_id">全选</a>
								<a href="javascript:;" class="dropdown-item check_select_btn" attr-type="reverse" attr-bind="check_id">反选</a>
								<a href="javascript:;" class="dropdown-item check_select_btn" attr-type="cancel" attr-bind="check_id">取消</a>
							</div>
						</div>
						<div class="input-group-prepend">
							<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
							 aria-expanded="false">操作选中的</button>
							<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 37px, 0px);">
								<a href="javascript:;" class="dropdown-item Fast_Bat" attr-model="cats" attr-type="enable" attr-class=".check_id">启用</a>
								<a href="javascript:;" class="dropdown-item Fast_Bat" attr-model="cats" attr-type="disable" attr-class=".check_id">禁用</a>
							</div>
						</div>
						<a href="javascript:;" class="btn btn-primary" id="Fast_Sort" attr-model="cats" attr-frm="cats_list_frm">更新排序</a>
					</div>
				</form>
				<div class="table-responsive-lg">
					<form action="" method="post" id="cats_list_frm">
						<table class="table table-centered mb-0">
							<thead>
								<tr>
									<th>选择</th>
									<th>栏目名称</th>
									<th>所属模型</th>
									<th>栏目排序</th>
									<th>栏目状态</th>
									<th>更新时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								{volist name='list' id="data"}
								<tr>
									<td>
										<div class="custom-control custom-checkbox">
											<input type="checkbox" class="custom-control-input check_id" id="check_id{$data.id}" value="{$data.id}" name="check_id[]">
											<label class="custom-control-label" for="check_id{$data.id}">ID:{$data.id}</label>
										</div>
									</td>
									<td>
										<span class="subtype_indent link">{$data.classname_indent}</span>
										<a href="{:url('document/index')}?cid={$data.id}" class="link">{$data.classname}【ID:{$data.id}】</a>
										<a href="{:url('document/publish')}?cid={$data.id}" class="badge badge-primary">发布信息</a>
									</td>
									<td>{$data.model_name}</td>
									<td>
										<input type="hidden" name="field_ids[]" value="{$data.id}" />
										<input type="number" class="form-control orderid_ipt" name="orderid_ipt[]" value="{$data.orderid}">
									</td>
									<td>
										{eq name="data.status" value="0"}
										<a href="" attr-model="cats" attr-id="{$data.id}" attr-field="status" attr-val="1" class="badge badge-primary Fast_Action">启用</a>
										{else /}
										<a href="" attr-model="cats" attr-id="{$data.id}" attr-field="status" attr-val="0" class="badge badge-secondary Fast_Action">禁用</a>
										{/eq}
									</td>
									<td title="{$data.posttime|date=" Y-m-d H:i:s",###}">{$data.posttime|date="m-d H:i",###}</td>
									<td class="table-action">
										<a href="javascript:;" class="btn btn-primary btn-sm edit_btn" attr-id="{$data.id}" data-toggle="modal" data-target="#edit_box"><i class="iconfont icon-icon_compile"></i>修改</a>
										<a href="javascript:;" class="btn btn-primary btn-sm add_sub_btn" attr-id="{$data.id}" data-toggle="modal" data-target="#edit_box"><i class="iconfont icon-plus-circle-fill"></i>创建子栏目</a>
										{neq name="AdminInfo.username" value="developer"}
										{eq name="data.isadmindel" value="0"}
										<a href="javascript:;" class="btn btn-danger btn-sm Fast_Del" attr-id="{$data.id}" attr-msg="您确认删除此栏目及子栏目？" attr-model="cats"><i class="iconfont icon-icon_delete_fill"></i>删除</a>
										{/eq}										
										{else /}
										<a href="javascript:;" class="btn btn-danger btn-sm Fast_Del" attr-id="{$data.id}" attr-msg="您确认删除此栏目及子栏目？" attr-model="cats"><i class="iconfont icon-icon_delete_fill"></i>删除</a>
										{/neq}										
									</td>
								</tr>
								{/volist}
							</tbody>
						</table>
					</form>
				</div>
				<!-- end table-responsive-->
			</div>
			<!-- end card body-->
		</div>
		<!-- end card -->
	</div>
	<!-- end col-->
</div>
<!-- END PAGE CONTENT-->
{/block}
{block name="modal_dig"}
<!-- Modal -->
<div class="modal fade" id="edit_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog modal-full-700">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title dig_title" id="myModalLabel"></h4>
				<button type="button" class="close" data-dismiss="modal">x</button>
			</div>
			<div class="modal-body">
				<form action="#" class="form-horizontal" id="edit_cats_frm">
					<input type="hidden" name="id" value="" />
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">选择所属栏目：</label>
						<div class="col-5">
							<select class="form-control" tabindex="1" name="parent">
								<option value="0">══顶级分类══</option>
								{$cats_tree}
							</select>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">栏目模型：</label>
						<div class="col-5">
							<select class="form-control" tabindex="1" name="mid">
								{volist name="model_list" id="data"}
								<option value="{$data.id}">{$data.model_name}</option>
								{/volist}
							</select>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">栏目名称：</label>
						<div class="col-5">
							<input type="text" name="classname" placeholder="请输入栏目名称" class="form-control ipt_check" data-type="string"
							 data-len="2-20" nullmsg="栏目名称不能为空" errormsg="栏目名称只能由2到20位的字母、汉字组成">
							<span class="font-13 text-muted"><span class="label label-important"> 必填</span></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">栏目描述：</label>
						<div class="col-5">
							<textarea class="large form-control" rows="5" name="description" placeholder="请输入栏目描述"></textarea>
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">栏目图片：</label>
						<div class="col-5 faceupload_box">
							<div class="picurl_upload" data-type="upload" attr-inputname="picurl" attr-value="" isCompress="1"></div>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">栏目排序：</label>
						<div class="col-5">
							<input type="text" name="orderid" placeholder="请输入栏目排序" class="form-control medium ipt_check" data-type="integer"
							 data-len="1-4" nullmsg="栏目排序不能为空" errormsg="栏目排序只能由1到4位的整数组成" value="{$orderid}">
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					{eq name="AdminInfo.username" value="developer"}
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">管理员是否能删除：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="isadmindel" id="isadmindel1" class="custom-control-input" value="0" checked="checked">
								<label class="custom-control-label" for="isadmindel1">可删除</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="isadmindel" id="isadmindel2" class="custom-control-input" value="1">
								<label class="custom-control-label" for="isadmindel2">不可删除</label>
							</div>
						</div>
					</div>
					{/eq}					
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">栏目状态：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="status" id="status1" class="custom-control-input" value="0" checked="checked">
								<label class="custom-control-label" for="status1">启用</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="status" id="status2" class="custom-control-input" value="1">
								<label class="custom-control-label" for="status2">禁用</label>
							</div>
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary Fast_Form_Post" attr-frm="#edit_cats_frm" attr-callback="reload"
				 attr-model="cats" attr-active="save_cats">保存</button>
			</div>
		</div>
	</div>
</div>
{/block}
